<template>
    <div class="meetingAdd">
        <el-dialog v-model="visible" destroy-on-close :close-on-press-escape="false" :close-on-click-modal="false"
            :show-close="false" align-center class="dialogAdd">
            <div class="my-header">
                <div class="title" style="display: flex; align-items: center;">
                    <img src="@/assets/images/rectangle07.png" alt="">
                    <div class="titleText">会议登记</div>
                </div>
                <img class="close" src="@/assets/images/close.png" @click="handleClose" alt="">
            </div>

            <div class="content">
                <el-form :model="state.formAdd" ref="formAddRef" :rules="rules" label-position="right">
                    <div class="top">
                        <div class="left">
                            <el-form-item label="班会类型" :label-width="formLabelWidth" prop="realName">
                                <el-select v-model="state.formAdd.realName" class="m-2" placeholder="班会类型" clearable>
                                    <el-option label="班前会" :value="1" />
                                    <el-option label="班会后" :value="2" />
                                </el-select>
                            </el-form-item>
                            <el-form-item label="主持人" :label-width="formLabelWidth" prop="realName">
                                <el-input v-model="state.formAdd.realName" autocomplete="off" />
                            </el-form-item>
                        </div>
                        <div class="right">
                            <el-form-item label="班组" :label-width="formLabelWidth" prop="realName">
                                <el-select v-model="state.formAdd.realName" class="m-2" placeholder="班组" clearable>
                                    <el-option label="锅炉一值" :value="1" />
                                    <el-option label="锅炉二值" :value="2" />
                                </el-select>
                            </el-form-item>
                            <el-form-item label="会议地点" :label-width="formLabelWidth" prop="realName">
                                <el-input v-model="state.formAdd.realName" autocomplete="off" />
                            </el-form-item>
                        </div>
                    </div>
                    <el-form-item label="召开时间" :label-width="formLabelWidth" prop="realName">
                        <el-date-picker style="width: 260px;" v-model="receiptTime" type="daterange" range-separator="-"
                            start-placeholder="开始日期" end-placeholder="结束日期" format="YYYY/MM/DD"
                            value-format="YYYY-MM-DD" @change="changeReceiptTime" :disabled-date="disabledDate"
                            unlink-panels />
                    </el-form-item>
                    <el-form-item label="出勤人员" class="w500" :label-width="formLabelWidth" prop="realName">
                        <el-input v-model="state.formAdd.realName" autocomplete="off" />
                    </el-form-item>
                    <el-form-item label="未出勤人员" class="w500" :label-width="formLabelWidth" prop="realName">
                        <el-input v-model="state.formAdd.realName" autocomplete="off" />
                    </el-form-item>
                    <el-form-item label="班会小结" :label-width="formLabelWidth" prop="realName">
                        <el-input v-model="state.formAdd.realName" autocomplete="off" :autosize="{ minRows: 4, maxRows: 6 }" type="textarea" />
                    </el-form-item>
                </el-form>
            </div>
        </el-dialog>
    </div>
</template>

<script lang="ts" setup>
import type { FormInstance, FormRules, CheckboxValueType } from 'element-plus'

const formLabelWidth = '115px'
let visible = ref(false);
const state = reactive({
    formAdd: {
        realName: '',
        createTimeStart: '',
        createTimeEnd: '',
    }
})
const props = defineProps({
    dialogVisible: {
        type: Boolean,
        default: false
    },
})

// from规则
const rules = reactive<FormRules>({

})
const emit = defineEmits(['closeDialog', 'confirmDialog']);

watch(() => props.dialogVisible, (newValue, oldValue) => {
    visible.value = newValue;
});

//关闭弹窗
const handleClose = () => {
    emit("closeDialog");
}


const receiptTime = ref('') as any;//接收时间

const changeReceiptTime = (val: string[]) => {
    console.log('val', val);
    if (val && val.length == 2) {
        state.formAdd.createTimeStart = val[0] + " 00:00:00";
        state.formAdd.createTimeEnd = val[1] + " 23:59:59";
    } else {
        state.formAdd.createTimeStart = "";
        state.formAdd.createTimeEnd = "";
    }
}

const disabledDate = (time: any) => {
    return time.getTime() > Date.now(); // 8.64e7 毫秒数代表一天
}
</script>

<style lang="scss" scoped>
.meetingAdd {
    :deep(.el-input__wrapper) {
        border-radius: 0px;
    }

    :deep(.el-tag) {
        height: 18px;
        margin: 5px 0 2px 6px;
    }

    :deep(.dialogAdd) {
        width: 995px;
        min-height: 600px;
        display: flex;
        flex-direction: column;
        position: relative;
        border-radius: 2px;
        background: rgba(255, 255, 255, 1);
        box-shadow: 0px 6px 16px -8px rgba(0, 0, 0, 0.08), 0px 9px 28px 0px rgba(0, 0, 0, 0.05), 0px 12px 48px 16px rgba(0, 0, 0, 0.03);

        .el-dialog__header {
            padding: 0;
        }

        .mimays::before {
            color: rgb(245, 108, 108);
            content: "*";
            margin-top: 3px;
            margin-right: 0;
        }

        .el-dialog__body {
            padding: 0;
        }

        // .el-input {
        //     width: 330px;
        // }

        .el-form {
            flex-direction: column;
        }

        .el-form-item {
            margin-bottom: 22px;
        }

        .my-header {
            height: 59px;
            padding: 8px 32px 4px 62px;
            margin-bottom: 36px;
            display: flex;
            align-items: center;
            flex-direction: row;
            justify-content: space-between;
            border-bottom: 1px dashed rgba(0, 0, 0, 1);

            .title {
                img {
                    height: 22px;
                    margin: 0 15px 0 0;
                }

                .titleText {
                    font-size: 16px;
                    line-height: 46px;
                    color: rgba(0, 0, 0, 1);
                }
            }

            .close {
                width: 25px;
                height: 25px;
                cursor: pointer;
            }
        }

        .content {
            padding: 0 72px;
            margin-bottom: 75px;

            .top {
                display: flex;

                // justify-content: space-between
                .right {
                    margin-left: 50px;
                }
            }
            .w500 {
                .el-input {
                    width: 500px;
                }
            }
        }

        .btn {
            position: absolute;
            bottom: 40px;
            right: 52px;

            .el-button--info {
                margin-left: 32px;
            }
        }

        .text_label {
            .el-form-item__label {
                word-spacing: 26px;
            }
        }
    }
}
</style>
